<?php
	require_once('../class/SanPhamDAO.php');
	require_once('../class/LoaiSanPhamDAO.php');
	require_once('../session.inc');
	$maSP = $_REQUEST['maSanPham'];
	$stt = $_REQUEST['stt'];
	$maGH = $_REQUEST['maGianHang'];
	$sanPham = SanPhamDAO::LaySanPhamTheoMa($maSP, 0);
	//$state = SanPhamDAO::CapNhatThongTinSanPham();
	$loaiSP = LoaiSanPhamDAO::LayLoaiSanPhamTheoMaLSP($sanPham->MaLoaiSP);
	$soLuongTon = $sanPham->SoLuong - SanPhamDAO::TinhSoLuongSanPhamDaMua($sanPham->Ma);
	// drop down list danh mục sàn phẩm
	$lstLoaiSP = LoaiSanPhamDAO::LayDanhSachLoaiSanPhamTheoMaGianHang($maGH);
	//
	$btnDel = '<input name="btnXoaSP" type="button" value="Xóa" onclick="funcXoaSP('.$sanPham->Ma.')"/>';
	$btnUpd = '<input name="btnCapNhatSP" type="button" value="Cập nhật" onclick="funcCapNhatSP('.$sanPham->Ma .','.$loaiSP->MaGianHang.','.$stt.')"/>';
	$check_area = '<input name="chkItem" type="checkbox" onclick="updateList1();" value="'.$sanPham->Ma.'"/>';
	$res = ' <tr id="SP'.$sanPham->Ma.'">
				<td>
					'.$check_area.'
				</td>
				<td>'.$stt.'</td>
				<td>'.$sanPham->Ma.'</td>
				<td>'.$sanPham->TenSanPham.'</td>
				<td>'.$sanPham->DonGiaGoc.'</td>
				<td>'.$sanPham->DonGiaBan.'</td>
				<td>'.$soLuongTon.'</td>
				<td>'.$loaiSP->TenLoaiSP.'</td>
				<td>'.$btnUpd.'</td>
				<td>'.$btnDel.'</td>
			</tr>
				';
	echo $res;
?>